package com.wannengbang.storemobile.homepage;


import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.codingending.popuplayout.PopupLayout;
import com.google.gson.Gson;
import com.gyf.immersionbar.ImmersionBar;
import com.wannengbang.storemobile.R;
import com.wannengbang.storemobile.base.BaseFragment;
import com.wannengbang.storemobile.base.DataCallBack;
import com.wannengbang.storemobile.bean.AliPushBean;
import com.wannengbang.storemobile.bean.BankInfoBean;
import com.wannengbang.storemobile.bean.BaseResponseBean;
import com.wannengbang.storemobile.bean.IndexMessageBean;
import com.wannengbang.storemobile.bean.LoginBean;
import com.wannengbang.storemobile.bean.StoreDeatilsBean;
import com.wannengbang.storemobile.bean.StoreListBean;
import com.wannengbang.storemobile.bean.StoreReceivedBean;
import com.wannengbang.storemobile.bean.UserInfoBean;
import com.wannengbang.storemobile.event.StoreDataEvent;
import com.wannengbang.storemobile.event.SwitchStoreEvent;
import com.wannengbang.storemobile.homepage.model.HomePageModelImpl;
import com.wannengbang.storemobile.homepage.model.IHomePageModel;
import com.wannengbang.storemobile.login.LoginActivity;
import com.wannengbang.storemobile.mine.ChooseLocationActivity;
import com.wannengbang.storemobile.mine.WeiXinAuthActivity;
import com.wannengbang.storemobile.mine.model.MineModelImpl;
import com.wannengbang.storemobile.utils.AMapManager;
import com.wannengbang.storemobile.utils.DateTimeUtil;
import com.wannengbang.storemobile.utils.NumberFormatUtils;
import com.wannengbang.storemobile.utils.SPManager;
import com.wannengbang.storemobile.utils.StringUtils;
import com.wannengbang.storemobile.utils.ToastUtil;
import com.wannengbang.storemobile.widget.CommonDialog;
import com.wannengbang.storemobile.widget.CommonNoTitleDialog;
import com.wannengbang.storemobile.widget.ViewLoading;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.util.Date;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 首页
 */
public class HomePageFragment extends BaseFragment {

    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_mobile)
    TextView tvMobile;
    @BindView(R.id.ll_order)
    LinearLayout llOrder;
    @BindView(R.id.ll_shop)
    LinearLayout llShop;
    @BindView(R.id.ll_income)
    LinearLayout llIncome;
    @BindView(R.id.ll_device)
    LinearLayout llDevice;
    @BindView(R.id.tv_order_money)
    TextView tvOrderMoney;
    @BindView(R.id.tv_status)
    TextView tvStatus;
    @BindView(R.id.ll_product_classify)
    LinearLayout llProductClassify;
    @BindView(R.id.ll_d0_code)
    LinearLayout llD0Code;
    @BindView(R.id.ll_d1_code)
    LinearLayout llD1Code;
    @BindView(R.id.ll_huabei_stages)
    LinearLayout llHuabeiStages;
    @BindView(R.id.ll_jiesuan_info)
    LinearLayout llJiesuanInfo;
    @BindView(R.id.ll_today_money)
    RelativeLayout llTodayMoney;
    @BindView(R.id.ll_address_updata)
    LinearLayout llAddressUpdata;
    @BindView(R.id.ll_increase_auth)
    LinearLayout llIncreaseAuth;
    @BindView(R.id.ll_intelligent_cashier)
    LinearLayout ll_intelligent_cashier;
    @BindView(R.id.ll_registration_information)
    LinearLayout ll_registration_information;
    @BindView(R.id.tv_channel_type)
    TextView tv_channel_type;
    private IHomePageModel homePageModel;
    private UserInfoBean userInfoBean;
    private CommonNoTitleDialog.Builder dialogBuild;
    private String start_time;
    private String end_time;
    private CommonDialog.Builder dialogTitleBuild;
    private AMapManager aMapManager;
    private int channel_type;
    private int id;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home_page, container, false);
        ButterKnife.bind(this, view);
        registerEventBus();
        initView();
        requestUserInfo();
        requestIncome();
        requestBankInfo();
        return view;
    }

    @Override
    public void initImmersionBar() {
        ImmersionBar.with(this)
                .statusBarDarkFont(true)
                .navigationBarDarkIcon(true)
                .navigationBarColor(R.color.white)
                .statusBarDarkFont(true, 0.2f)
                .init();
    }

    @Subscribe
    public void onAliPushBean(AliPushBean event) {
        requestIncome();
    }

    @Subscribe
    public void onSwitchStoreEvent(SwitchStoreEvent event) {
        requestUserInfo();
        requestIncome();
        requestBankInfo();
        getCurrentLocationCity();
    }

    public void initView() {
        homePageModel = new HomePageModelImpl();
        start_time = DateTimeUtil.format(new Date());
        end_time = DateTimeUtil.format(new Date());
    }

    /**
     * 第一个门店审核未通过提示
     */
    public void tips() {
        if (userInfoBean == null) {
            return;
        }
        int pay_channel_status = userInfoBean.getData().getPay_channel_status();
        int quick_income = userInfoBean.getData().getQuick_income();
        //审核未通过
        if (pay_channel_status == 4) {
            if (quick_income == 2) {
                dialogBuild = new CommonNoTitleDialog.Builder(mActivity);
                dialogBuild.setMessage(userInfoBean.getData().getReject_msg());
                dialogBuild.setPositiveButton("立即修改", v -> {
                    dialogBuild.dismiss();
                    ViewLoading.showProgress(mActivity);
                    new HomePageModelImpl().requestStoreProfile(new DataCallBack<StoreDeatilsBean>() {
                        @Override
                        public void onSuccessful(StoreDeatilsBean bean) {
                            if (bean.getData() != null) {
                                EventBus.getDefault().postSticky(new StoreDataEvent(bean.getData()));
                                Intent intent = new Intent(mActivity, EBankStoreDataActivity.class);
                                mActivity.startActivity(intent);
                            }
                        }

                        @Override
                        public void onFailed(String msg, String code) {

                        }
                    });
                });
                dialogBuild.setNegativeButton("取消", v -> dialogBuild.dismiss());
                dialogBuild.setCancelable(false);
                dialogBuild.show();
            } else {
                dialogBuild = new CommonNoTitleDialog.Builder(mActivity);
                dialogBuild.setMessage(userInfoBean.getData().getReject_msg());
                dialogBuild.setPositiveButton("确定", v -> {
                    dialogBuild.dismiss();
                });
                dialogBuild.setNegativeButton("取消", v -> dialogBuild.dismiss());
                dialogBuild.setCancelable(false);
                dialogBuild.show();
            }

        }
        //未提交商户资料
        if (pay_channel_status == 0) {
            if (quick_income == 2) {
                dialogBuild = new CommonNoTitleDialog.Builder(mActivity);
                dialogBuild.setMessage("请提交商户资料");
                dialogBuild.setPositiveButton("立即前往", v -> {
                    dialogBuild.dismiss();
                    Intent intent1 = new Intent(mActivity, EBankStoreDataActivity.class);
                    intent1.putExtra("type", "1");
                    startActivity(intent1);
                });
                dialogBuild.setNegativeButton("取消", v -> dialogBuild.dismiss());
                dialogBuild.setCancelable(false);
                dialogBuild.show();
            }
        }
    }

    /**
     * 门店信息
     */
    public void requestUserInfo() {

        new MineModelImpl().requestMine(new DataCallBack<UserInfoBean>() {
            @Override
            public void onSuccessful(UserInfoBean bean) {

                Log.e("门店信息", new Gson().toJson(bean));

                userInfoBean = bean;
                SPManager.getInstance().saveUserInfoJson(new Gson().toJson(bean));
                id = bean.getData().getId();


                String yinsheng_sys_flowId = StringUtils.nullString(bean.getData().getYinsheng_sys_flowId());

                if ("".equals(yinsheng_sys_flowId) && (channel_type == 1 || channel_type == 2)) {
                    //弹出补充信息
                    initCrpGenderDialog();
                }


                tvName.setText(bean.getData().getName());
                tvMobile.setText(SPManager.getInstance().getUserMobile());
                int pay_channel_status = bean.getData().getPay_channel_status();
                //channel_type  1 银盛标准版 2银盛智能版
                channel_type = bean.getData().getChannel_type();

                if (channel_type == 2) {
                    tv_channel_type.setText("智能版");
                } else {
                    tv_channel_type.setText("标准版");
                }

                int quick_income = bean.getData().getQuick_income();
                if (pay_channel_status == 0) {
                    if (quick_income == 2) {
                        tvStatus.setText("请提交商户资料，点击提交");
                    } else {
                        tvStatus.setText("请联系服务商提交商户资料");
                    }
                }
                if (pay_channel_status == 1 || pay_channel_status == 2 || pay_channel_status == 5) {
                    tvStatus.setText("已提交资料，请等待审核(1个工作日内)");
                }
                if (pay_channel_status == 3) {
                    tvStatus.setText("已审核成功，可以正常收银");
                }
                if (pay_channel_status == 4) {
                    tvStatus.setText("审核未通过，点击查看");
                }
            }

            @Override
            public void onFailed(String msg, String code) {

            }
        });
    }


    private boolean isViewCreated; // 界面是否已创建完成
    private boolean isVisibleToUser; // 是否对用户可见

    /**
     * Fragment 创建期间setUserVisibleHint()方法是在onActivityCreated()之前被调用
     */
    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        this.isVisibleToUser = isVisibleToUser;
        tryLoadData();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        isViewCreated = true;
        tryLoadData();
    }

    public void tryLoadData() {
        if (isViewCreated && isVisibleToUser) {
            requestIncome();
            requestUserInfo();
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        requestUserInfo();
        requestIncome();
    }

    /**
     * 收益
     */
    private void requestIncome() {
        homePageModel.requestStoreReceived(start_time, end_time, new DataCallBack<StoreReceivedBean>() {
            @Override
            public void onSuccessful(StoreReceivedBean bean) {
                if (bean.getData() != null) {
                    if (!TextUtils.isEmpty(bean.getData().getPaid_order_fee())) {
                        String money = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(bean.getData().getPaid_order_fee()) / 100);
                        tvOrderMoney.setText(money);
                    } else {
                        tvOrderMoney.setText("0");
                    }
                }
            }

            @Override
            public void onFailed(String msg, String code) {

            }
        });
    }

    /**
     * 信用卡认证列表
     */
    public void requestBankInfo() {
        new MineModelImpl().requestMine(new DataCallBack<UserInfoBean>() {
            @Override
            public void onSuccessful(UserInfoBean bean) {
                int pay_channel_status = bean.getData().getPay_channel_status();
                int quick_income = bean.getData().getQuick_income();
                if (isDestroy()) {
                    return;
                }
                //资料未上传
                if (pay_channel_status == 0 && quick_income == 2) {
                    dialogBuild = new CommonNoTitleDialog.Builder(mActivity);
                    dialogBuild.setMessage("请提交商户资料");
                    dialogBuild.setPositiveButton("立即前往", v -> {
                        dialogBuild.dismiss();
                        Intent intent = new Intent(mActivity, EBankStoreDataActivity.class);
                        intent.putExtra("type", "1");
                        startActivity(intent);
                    });
                    dialogBuild.setNegativeButton("取消", v -> dialogBuild.dismiss());
                    dialogBuild.setCancelable(false);
                    dialogBuild.show();
                    return;
                }
                //审核失败 修改资料
                if (pay_channel_status == 4 && quick_income == 2) {
                    dialogBuild = new CommonNoTitleDialog.Builder(mActivity);
                    dialogBuild.setMessage(bean.getData().getReject_msg());
                    dialogBuild.setPositiveButton("立即修改", v -> {
                        dialogBuild.dismiss();
                        ViewLoading.showProgress(mActivity);
                        new HomePageModelImpl().requestStoreProfile(new DataCallBack<StoreDeatilsBean>() {
                            @Override
                            public void onSuccessful(StoreDeatilsBean bean) {
                                if (bean.getData() != null) {
                                    EventBus.getDefault().postSticky(new StoreDataEvent(bean.getData()));
                                    Intent intent = new Intent(mActivity, EBankStoreDataActivity.class);
                                    mActivity.startActivity(intent);
                                }
                            }

                            @Override
                            public void onFailed(String msg, String code) {

                            }
                        });
                    });
                    dialogBuild.setNegativeButton("取消", v -> dialogBuild.dismiss());
                    dialogBuild.setCancelable(false);
                    dialogBuild.show();
                    return;
                }
                homePageModel.requestBankInfo(new DataCallBack<BankInfoBean>() {
                    @Override
                    public void onSuccessful(BankInfoBean bean) {
                        if (isDestroy()) {
                            return;
                        }
                        //审核通过  未申请秒到
                        if (pay_channel_status == 3 && quick_income == 2 && bean.getData().size() == 0) {
                            dialogBuild = new CommonNoTitleDialog.Builder(mActivity);
                            dialogBuild.setMessage("请前往“申请秒到”页面进行申请秒到");
                            dialogBuild.setPositiveButton("立即前往", v -> {
                                dialogBuild.dismiss();
                                skipToActivity(IncreaseAuthActivity.class);
                            });
                            dialogBuild.setNegativeButton("取消", v -> dialogBuild.dismiss());
                            dialogBuild.setCancelable(false);
                            dialogBuild.show();
                            return;
                        }
                        requestMessage();
                    }

                    @Override
                    public void onFailed(String msg, String code) {

                    }
                });
            }

            @Override
            public void onFailed(String msg, String code) {

            }
        });

    }

    public void requestMessage() {
        new MineModelImpl().requestIndexMessage(1, new DataCallBack<IndexMessageBean>() {
            @Override
            public void onSuccessful(IndexMessageBean bean) {
                if (isDestroy()) {
                    return;
                }
                if (bean.getData().getItemList() != null && bean.getData().getItemList().size() > 0) {
                    //1新消息  0已读消息
                    if (bean.getData().getItemList().get(0).getIs_new() == 1) {
                        dialogTitleBuild = new CommonDialog.Builder(mActivity);
                        dialogTitleBuild.setTitle("新消息通知");
                        dialogTitleBuild.setMessage(bean.getData().getItemList().get(0).getContent());
                        dialogTitleBuild.setPositiveButton("我知道了", v -> {
                            requestSaveNewStatus(bean.getData().getItemList().get(0).getMessage_no());
                            dialogTitleBuild.dismiss();
                        });
                        dialogTitleBuild.setNegativeButton("取消", v -> dialogTitleBuild.dismiss());
                        dialogTitleBuild.setCancelable(false);
                        dialogTitleBuild.show();
                    }
                }
            }

            @Override
            public void onFailed(String msg, String code) {

            }
        });
    }

    public void requestSaveNewStatus(String message_no) {
        homePageModel.requestSaveNewStatus(message_no, new DataCallBack<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean) {

            }

            @Override
            public void onFailed(String msg, String code) {

            }
        });
    }

    public void getCurrentLocationCity() {
        aMapManager = new AMapManager();
        aMapManager.getOnceLocation(aMapLocation -> {
            aMapManager.onDestroy();
            if (aMapLocation.getErrorCode() == 0) {//获得了定位
                requestUpLngLat(aMapLocation.getLatitude(), aMapLocation.getLongitude());
            } else {
                ToastUtil.showShort("定位失败，检查定位权限");
            }
        });
    }

    public void requestUpLngLat(double latitude, double longitude) {
        String lat = NumberFormatUtils.formatDecimal6(latitude + "");
        String lng = NumberFormatUtils.formatDecimal6(longitude + "");
        new MineModelImpl().requestUpLngLat(lat, lng, lng + "|" + lat, "", new DataCallBack<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean) {

            }

            @Override
            public void onFailed(String msg, String code) {

            }
        });
    }

    @OnClick({R.id.ll_today_money, R.id.ll_order, R.id.ll_shop, R.id.ll_income, R.id.ll_device, R.id.ll_product_classify,
            R.id.ll_address_updata, R.id.tv_status,
            R.id.ll_huabei_stages, R.id.ll_jiesuan_info,
            R.id.ll_d0_code, R.id.ll_d1_code,
            R.id.ll_increase_auth, R.id.ll_wx_auth,
            R.id.ll_switch_store, R.id.ll_order_caigou, R.id.ll_intelligent_cashier, R.id.ll_registration_information})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_order:
                skipToActivity(OrderListActivity.class);
                break;
            case R.id.ll_today_money:
                skipToActivity(OrderListActivity.class);
                break;
            case R.id.ll_shop:
                skipToActivity(ProductListActivity.class);
                break;
            case R.id.ll_income:
                skipToActivity(SubsidyListActivity.class);
                break;
            case R.id.ll_device:
                skipToActivity(DeviceListActivity.class);
                break;
            case R.id.ll_product_classify:
                skipToActivity(ProductClassifyActivity.class);
                break;
            case R.id.ll_address_updata:
                if (userInfoBean == null) {
                    return;
                }
                Intent intent = new Intent(mActivity, ChooseLocationActivity.class);
                intent.putExtra("store_no", userInfoBean.getData().getStore_no());
                intent.putExtra("lat", userInfoBean.getData().getLat() == null ? "" : userInfoBean.getData().getLat());
                intent.putExtra("lng", userInfoBean.getData().getLng() == null ? "" : userInfoBean.getData().getLng());
                mActivity.startActivity(intent);
                break;
            case R.id.ll_huabei_stages:
                break;
            case R.id.ll_jiesuan_info:
                if (userInfoBean == null) {
                    return;
                }
//                if (userInfoBean.getData().getQuick_income() == 0) {
//                    ToastUtil.showShort("此商户暂不支持");
//                    return;
//                }
                int pay_channel_status = userInfoBean.getData().getPay_channel_status();
                int channel_type = userInfoBean.getData().getChannel_type();
                Log.e("====", "pay_channel_status" + pay_channel_status);
                Log.e("====", "channel_type" + channel_type);
                if (pay_channel_status == 3 && 2 == channel_type) {
                    skipToActivity(SettlementInfoActivity.class);
                } else {
                    if (pay_channel_status == 0) {
                        ToastUtil.showShort("请提交商户资料");
                    } else if (pay_channel_status == 1 || pay_channel_status == 2 || pay_channel_status == 5) {
                        ToastUtil.showShort("已提交资料，请审核通过之后再修改结算人信息");
                    } else if (pay_channel_status == 4) {
                        ToastUtil.showShort("审核未通过，无法查看");
                    } else {
                        ToastUtil.showShort("该账号类型不能审核");
                    }

                }
                break;
            case R.id.tv_status:
                tips();
                break;
            case R.id.ll_d0_code:
                skipToActivity(D0CodeActivity.class);
                break;
            case R.id.ll_d1_code:
                skipToActivity(D1CodeActivity.class);
                break;
            case R.id.ll_increase_auth:
                if (userInfoBean == null) {
                    return;
                }
                if (userInfoBean.getData().getQuick_income() == 0) {
                    ToastUtil.showShort("此商户暂不支持");
                    return;
                }
                pay_channel_status = userInfoBean.getData().getPay_channel_status();
                if (pay_channel_status == 3) {
                    skipToActivity(IncreaseAuthActivity.class);
                } else {
                    if (pay_channel_status == 0) {
                        ToastUtil.showShort("请提交商户资料");
                    }
                    if (pay_channel_status == 1 || pay_channel_status == 2 || pay_channel_status == 5) {
                        ToastUtil.showShort("已提交资料，请审核通过之后再申请秒到");
                    }
                    if (pay_channel_status == 4) {
                        ToastUtil.showShort("审核未通过，不能申请秒到");
                    }
                }
                break;
            case R.id.ll_wx_auth:

                if (this.channel_type == 1) {
                    skipToActivity(WeiXinActivity.class);
                } else {
                    skipToActivity(WeiXinAuthActivity.class);
                }


                break;
            case R.id.ll_switch_store:
                if (userInfoBean == null) {
                    return;
                }
                intent = new Intent(mActivity, SwitchStoreActivity.class);
                intent.putExtra("store_no", userInfoBean.getData().getStore_no());
                mActivity.startActivity(intent);
                break;
            case R.id.ll_order_caigou:
                intent = new Intent(mActivity, PurchaseOrderActivity.class);
                mActivity.startActivity(intent);
                break;
            case R.id.ll_intelligent_cashier:
                //channel_type  1 银盛标准版 2银盛智能版
                // 如果不是智能版商户 就直接跳转到 智能版进件页面

                if (this.channel_type == 2) {
                    intent = new Intent(mActivity, IntelligentCashierActivity.class);
                    mActivity.startActivity(intent);
                } else {
                    homePageModel.requestStoreIndex(new DataCallBack<StoreListBean>() {
                        @Override
                        public void onSuccessful(StoreListBean bean) {
                            List<StoreListBean.DataBean.ItemListBean> itemList = bean.getData().getItemList();

                            boolean isChannel = true;

                            for (int i = 0; i < itemList.size(); i++) {
                                int channel_type = itemList.get(i).getChannel_type();
                                if (isChannel) {
                                    if (channel_type == 2) {
                                        isChannel = false;
                                        requestChangeStore(itemList.get(i).getStore_no());
                                    }
                                }
                            }

                            if (isChannel) {
                                int agent_id = userInfoBean.getData().getAgent_id();
                                Intent intent = new Intent(getActivity(), IncomingUserTypeActivity.class);
                                intent.putExtra("agent_id", agent_id);
                                intent.putExtra("channel_type", "2");
                                startActivity(intent);
                            }
                        }

                        @Override
                        public void onFailed(String msg, String code) {

                        }
                    });


                }
                break;
            case R.id.ll_registration_information:
                intent = new Intent(mActivity, RegistrationInformationActivity.class);
                intent.putExtra("id", id);
                mActivity.startActivity(intent);
                break;
        }
    }


    public void requestChangeStore(String store_no) {
        homePageModel.requestChangeStore(store_no, new DataCallBack<LoginBean>() {
            @Override
            public void onSuccessful(LoginBean bean) {
                ToastUtil.showShort("切换成功");
                SPManager.getInstance().saveToken(bean.getData().getAccess_token());
                EventBus.getDefault().post(new SwitchStoreEvent());

                Intent intent = new Intent(mActivity, IntelligentCashierActivity.class);
                mActivity.startActivity(intent);

//                finish();
            }

            @Override
            public void onFailed(String msg, String code) {

            }
        });
    }

    private void initCrpGenderDialog() {
        //2.使用View作为弹出布局的内容
        View layout = View.inflate(getActivity(), R.layout.dialog_supplementary_information_layout, null);

        TextView tv_crp_gender_1 = layout.findViewById(R.id.tv_crp_gender_1);
        TextView tv_crp_gender_2 = layout.findViewById(R.id.tv_crp_gender_2);


        final PopupLayout popupLayout = PopupLayout.init(getActivity(), layout);
        tv_crp_gender_1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popupLayout.dismiss();
            }
        });
        tv_crp_gender_2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //channel_type  1 银盛标准版 2银盛智能版
                //supplementary_information  1 请提交商户资料
                int agent_id = userInfoBean.getData().getAgent_id();
                if (channel_type == 2) {
                    Intent intent = new Intent(getActivity(), IncomingUserTypeActivity.class);
                    intent.putExtra("agent_id", agent_id);
                    intent.putExtra("channel_type", "2");
                    intent.putExtra("supplementary_information", "1");
                    startActivity(intent);
                    popupLayout.dismiss();
                } else {
                    Intent intent = new Intent(getActivity(), IncomingUserTypeActivity.class);
                    intent.putExtra("agent_id", agent_id);
                    intent.putExtra("channel_type", "1");
                    intent.putExtra("supplementary_information", "1");
                    startActivity(intent);
                    popupLayout.dismiss();
                }
            }
        });
        //默认从底部弹出
        popupLayout.show(PopupLayout.POSITION_CENTER);
    }
}
